namespace Vanilla.UI

import System

class Button (Frame):
	// LABEL
	class Label (Vanilla.UI.Label):
		def constructor (p as Button, t as string):
			super(p,t)
	
	// STATE
	enum State:
		Normal
		Pressed
		Processing
	
	CurrentState as State = State.Normal
	
	// TEXT
	Text as string:
		get:
			l = Child as Label
			return l.Text if l != null
			return ""
		set: 
			l = Child as Label
			l.Text = value if l != null
	
	// CALLBACK
	public Callback as callable= {print "no callback"}
	
	// CONSTRUCTORS
	def constructor (p as Box, c as callable):
		super(p)
		PassMouseEventsToChildren = false
		Callback = c
	
	def constructor (p as Box):
		self(p, {print "no callback"})
	
	def constructor (p as Box, s as string, c as callable):
		self(p, c)
		Child = Label(self,s)
	
	def constructor (p as Box, s as string):
		self(p, s, {print "no callback"})
	
	// EVENTS
	override def Click (b as MouseButton, x as double, y as double):
		Callback() unless b != MouseButton.Left
		
	override def ContainsMouseAt (x as double, y as double):
		return Contains(x,y)
